*/
#include <cmath> // for sin, cos, acos
-#include <cstdio> // for snprintf
#include <QtCore/QString> // for QString
+#include <QtCore/QVector> // for QVector
#include <QtCore/QtGlobal> // for foreach
#include "defs.h"
{
int symbols = inifile_readint_def(inifile, "Overlay", "Symbols", -1);
- for (int i = 1; i <= symbols; i++) {
- char symbol[32];
+ for (int i = 1; i <= symbols; ++i) {
- snprintf(symbol, sizeof(symbol), "Symbol %d", i);
+ QString symbol = QString("Symbol %1").arg(i);
OVL_SYMBOL_TYP type = (OVL_SYMBOL_TYP) inifile_readint_def(inifile, symbol, "Typ", 0);
int points = inifile_readint_def(inifile, symbol, "Punkte", -1);
QString lon;
switch (type) {
- char coord[32];
Waypoint* wpt;
int group;
trk->rte_name = QString("Track %1").arg(track_ct);
}
- for (int j = 0; j < points; j++) {
+ for (int j = 0; j < points; ++j) {
wpt = new Waypoint;
- snprintf(coord, sizeof(coord), "YKoord%d", j);
- lat = inifile_readstr(inifile, symbol, coord);
- if (!lat.isNull()) {
- wpt->latitude = lat.toDouble();
- } else {
+ lat = inifile_readstr(inifile, symbol, QString("YKoord%1").arg(j));
+ if (lat.isNull()) {
+ delete wpt;
continue;
}
+ wpt->latitude = lat.toDouble();
- snprintf(coord, sizeof(coord), "XKoord%d", j);
- lon = inifile_readstr(inifile, symbol, coord);
- if (!lon.isNull()) {
- wpt->longitude = lon.toDouble();
- } else {
+ lon = inifile_readstr(inifile, symbol, QString("XKoord%1").arg(j));
+ if (lon.isNull()) {
+ delete wpt;
continue;
}
+ wpt->longitude = lon.toDouble();
if (group > 1) {
route_add_wpt(rte, wpt);
wpt->shortname = symbol;
lat = inifile_readstr(inifile, symbol, "YKoord");
- if (!lat.isNull()) {
- wpt->latitude = lat.toDouble();
- } else {
+ if (lat.isNull()) {
+ delete wpt;
continue;
}
+ wpt->latitude = lat.toDouble();
lon = inifile_readstr(inifile, symbol, "XKoord");
- if (!lon.isNull()) {
- wpt->longitude = lon.toDouble();
- } else {
+ if (lon.isNull()) {
+ delete wpt;
continue;
}
+ wpt->longitude = lon.toDouble();
waypt_add(wpt);
break;
}
bool
-inifile_has_section(const inifile_t* inifile, const char* section)
+inifile_has_section(const inifile_t* inifile, const QString& section)
{
- return inifile->sections.contains(QString(section).toLower());
+ return inifile->sections.contains(section.toLower());
}
/*
*/
int
-inifile_readint_def(const inifile_t* inifile, const char* section, const char* key, const int def)
+inifile_readint_def(const inifile_t* inifile, const QString& section, const QString& key, const int def)
{
int result;
inifile_t* inifile_init(const QString& filename, const char* myname);
void inifile_done(inifile_t* inifile);
-bool inifile_has_section(const inifile_t* inifile, const char* section);
+bool inifile_has_section(const inifile_t* inifile, const QString& section);
/*
inifile_readstr:
inifile_readint_def:
if found inifile_readint_def returns value of key, otherwise a default value "def"
*/
-int inifile_readint_def(const inifile_t* inifile, const char* section, const char* key, int def);
+int inifile_readint_def(const inifile_t* inifile, const QString& section, const QString& key, int def);
#endif